A dynamic link library (DLL) is a collection of programs or program files, any of which are typically called when needed by a larger main program. A DLL may contain source code to do a variety of functions. For instance, a DLL is often used to enable the main program to communicate with a specific device such as a printer or scanner.
One advantage of DLLs is that since they are not loaded into random access memory (RAM) with the main program, space is saved in RAM. Rather, when and if a DLL is needed, then it is loaded and run. For example, when a user is editing a document, the printer DLL need not be loaded into RAM. If the user decides to print the document, then the word processing application causes the printer DLL to be loaded and run. The same DLL can be shared between several tasks rather than each task containing copies of the routines it uses.
A DLL is an executable file that traditionally cannot be run independently. In other words, a DLL can only be run by being called from another executable file. This is typically accomplished through subroutine calls. For instance, the executable for the main program may be compiled with a library of “stubs” which allow link errors to be detected at compile-time. Then, at run-time, the library calls may be patched with the addresses of the real shared library routines, possibly via a jump table. The use of subroutine calls is disadvantageous for several reasons. First, there is a substantial amount of overhead involved in calling each subroutine and returning to the main program. Second, maintenance of the jump table and the time to perform a lookup in the jump table is substantial. Third, it is important that the correct version of the libraries be linked. Since linking is performed during compile-time, code modifications of the libraries typically requires recompilation to link the correct versions of the libraries.
An alternative to performing subroutine calls is to make library calls part of the operating system kernel and enter each of them via a trap instruction. However, similar to the use of subroutine calls, this alternative requires a call and return for each library call. Accordingly, this is generally as inefficient as an ordinary subroutine call.
In view of the above, it would be desirable if a mechanism for linking DLLs to reduce the required execution time were developed. Moreover, it would be desirable if DLLs could be linked such that re-compilation were not required upon modification of the DLLs.